package com.dk.controller;

import com.dk.pojo.CodeRule;
import com.dk.pojo.WmMaterialStock;
import com.dk.result.PageResult;
import com.dk.result.Result;
import com.dk.result.ResultConstant;
import com.dk.service.StockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LTZ
 * @create 2023/5/11
 */
@RestController
@RequestMapping("stock")
@Api(tags = "库存现有量接口文档")
public class StockController {

    @Autowired
    private StockService stockService;

    @GetMapping("getStockInfo")
    @ApiOperation("库存现有量模糊查询和分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前页"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数"),
            @ApiImplicitParam(name = "itemCode", value = "产品物料编码"),
            @ApiImplicitParam(name = "itemName", value = "产品物料名称"),
            @ApiImplicitParam(name = "warehouseName", value = "仓库名称"),
            @ApiImplicitParam(name = "vendorName", value = "供应商名称"),
    })
    public Result getStockInfo(@RequestParam(defaultValue = "1")Integer pageNum,
                                  @RequestParam(defaultValue = "5") Integer pageSize,
                                  String itemCode, String itemName, String warehouseName,String vendorName){
        PageResult<WmMaterialStock> result = stockService.getStockInfo(pageNum,pageSize,itemCode,itemName,warehouseName,vendorName);
        return new Result(ResultConstant.CODE,ResultConstant.MESSAGE,result);
    }

    @PostMapping("addStock")
    public void addStock(@RequestBody WmMaterialStock stock){
        stockService.addStock(stock);
    }
}